package gdma.hqdes.service;

import gdma.hqdes.bean.*;
import org.springframework.data.domain.Page;

import javax.annotation.Nullable;
import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * @Author wangyue
 * @Version 3.0
 * @Date 2024-07-13
 */
public interface UnitService {

    Unit getUnit(long unitId);

    Unit getUnitByShortName(String shortName);

    Unit getUnitByShortPrefix(String shortPrefix);

    List<Unit> getChildUnits(long parentUnitId);

    List<Unit> getAuthorizedUnits(long userId);

    List<Long> getAuthorizedUnitIds(long userId);

    List<Unit> getUnits(int scope);

    Page<Unit> listUnits(@Nullable Long id, @Nullable Collection<Long> ids, @Nullable Long parentId, @Nullable String name, @Nullable Integer scope, @Nullable Integer scope0, @Nullable String areaTag, int... pagination);

    Map<String, List<Unit>> getAreaUnitsMap(int scope);

    void saveUnit(Unit unit);

    UnitScore getScore(long projectId, long unitId, long indexId);

    void saveScore(UnitScore score);

    List<UnitScoreUpdate> getScoreUpdates(long scoreId);

    void logScoreUpdate(UnitScoreUpdate scoreUpdate);

    void saveScoreArg(UnitScoreArg scoreArg);

    void deleteScoreArg(Long id);

    void saveScoreAtt(UnitScoreAtt scoreAtt);

    void deleteScoreAtt(Long id);

    List<UnitScore> getThinUnitScores(long projectId);

    List<UnitScore> getUnitScores(long projectId, long unitId);

    UnitMember getMember(long userId);

    List<UnitMember> listMembers(long unitId);

    List<UnitStat> statUnitScores(HqdProject project, Collection<Long> unitIds, Collection<Long> indexIds);

    List<YearStat> statHistoryUnitScores(Collection<Long> projectIds, Collection<Long> unitIds, Collection<Long> indexIds);

    List<UnitStat2> notifyUnitScoresToReport(HqdProject project, Collection<Long> unitIds, Collection<String> roles);

    List<UnitStat2> notifyUnitScoresToAudit(HqdProject project, Collection<Long> unitIds, Collection<String> roles);

    List<Unit> listRecentUpdatedUnits(HqdProject project, @Nullable Collection<Long> unitIds, @Nullable String name, @Nullable String areaTag, @Nullable Collection<Long> notifyingUnitIds);

    int purgeMember(long userId);

    int purgeUnit(long unitId);

}
